home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / LIFER__ / PROTO / P / PDOMENUL.C < prev    next >
Text File  |  1991-07-23  |  6KB  |  236 lines

  1. /*  PDoMenuLife                                                              Handle a selection of the menu bar */
  2.  
  3. /* Unit name:  PDoMenuLife.c   */
  4. /* Function:  This module calls the appropiate menu list */
  5. /*      handler routine. */
  6. /* History: 7/23/91 Original by Prototyper 3.0   */
  7.  
  8.  
  9. #include "PCommonLife.h"    /* Common */
  10. #include "Common_Life.h"    /* Common */
  11. #include "PUtils_Life.h"    /* General Utilities */
  12. #include "Utils_Life.h"    /* General Utilities */
  13.  
  14. #include "AppleMenu.h"    /* Menu handlers */
  15. #include "FileMenu.h"    /* Menu handlers */
  16. #include "EditMenu.h"    /* Menu handlers */
  17. #include "PA_Life_Alert.h"    /* Alert */
  18. #include "PD_LIFE_INPUT.h"    /* Modal Dialog */
  19. #include "PMD_LIFE_WINDOW.h"    /* Modeless Dialog */
  20. #include "DoMenuLife.h"    /* Extra menu handler */
  21.  
  22. #include "PDoMenuLife.h"    /* This file */
  23.  
  24.  
  25.  
  26.  
  27. /* ======================================================= */
  28.  
  29. void DoMenuApple(short theItem);                                        /* Handle this menu list */
  30. void DoMenuFile(short theItem);                                          /* Handle this menu list */
  31. void DoMenuEdit(short theItem);                                          /* Handle this menu list */
  32.  
  33. /* ======================================================= */
  34.  
  35.  
  36. /* ======================================================= */
  37.  
  38.  
  39. /* Routine: DoMenuApple */
  40. /* Purpose: Handle all menu items in this list */
  41.  
  42. void DoMenuApple( theItem)                                               /* Handle this menu selection */
  43. short        theItem;
  44. {
  45.         Boolean    SkipProcessing;                                           /* TRUE says skip processing */
  46.         short    DNA;                                                           /* For opening DAs */
  47.         Str255    DAName;                                                    /* For getting DA name */
  48.         GrafPtr    SavePort;                                                 /* Save current port when opening DAs */
  49.  
  50.  
  51.  
  52.         SkipProcessing = FALSE;                                             /* Set to not skip the processing of this menu item */
  53.  
  54.         Do_AppleMenu(TRUE,theItem,&SkipProcessing);                 /* Pre menu handler */
  55.  
  56.         if (SkipProcessing == FALSE)                                       /* See if process the menu list */
  57.             {
  58.  
  59.                 switch (theItem) {                                              /* Handle all commands in this menu list */
  60.  
  61.                         case MItem_About:
  62.                                 break;
  63.  
  64.                         default:                                                     /* Handle the DAs */
  65.                                     GetPort(&SavePort);                          /* Save the current port */
  66.                                     GetItem(Menu_Apple, theItem, DAName);/* Get the name of the DA selected */
  67.                                     DNA = OpenDeskAcc(DAName);               /* Open the DA selected */
  68.                                     SetPort(SavePort);                             /* Restore to the saved port */
  69.                                     break;
  70.  
  71.                 }                                                                   /* End of item case */
  72.  
  73.             }                                                                      /* End of not SkipProcessing */
  74.  
  75.         Do_AppleMenu(FALSE,theItem,&SkipProcessing);               /* Post menu handler */
  76.  
  77. }                                                                                /* End of procedure */
  78.  
  79. /* ======================================================= */
  80.  
  81.  
  82. /* Routine: DoMenuFile */
  83. /* Purpose: Handle all menu items in this list */
  84.  
  85. void DoMenuFile( theItem)                                                 /* Handle this menu selection */
  86. short        theItem;
  87. {
  88.         Boolean    SkipProcessing;                                           /* TRUE says skip processing */
  89.  
  90.  
  91.  
  92.         SkipProcessing = FALSE;                                             /* Set to not skip the processing of this menu item */
  93.  
  94.         Do_FileMenu(TRUE,theItem,&SkipProcessing);                   /* Pre menu handler */
  95.  
  96.         if (SkipProcessing == FALSE)                                       /* See if process the menu list */
  97.             {
  98.  
  99.                 switch (theItem) {                                              /* Handle all commands in this menu list */
  100.  
  101.                         case MItem_New:
  102.                                 break;
  103.  
  104.                         case MItem_Open:
  105.                                 break;
  106.  
  107.                         case MItem_Close:
  108.                                 break;
  109.  
  110.                         case MItem_Save:
  111.                                 break;
  112.  
  113.                         case MItem_Save_As:
  114.                                 break;
  115.  
  116.                         case MItem_Revert_to_Saved:
  117.                                 break;
  118.  
  119.                         case MItem_Page_Setup:
  120.                                 break;
  121.  
  122.                         case MItem_Print:
  123.                                 break;
  124.  
  125.                         case MItem_Quit:
  126.                                 doneFlag = TRUE;
  127.                                 break;
  128.  
  129.                         default:
  130.                                     break;
  131.  
  132.                 }                                                                   /* End of item case */
  133.  
  134.             }                                                                      /* End of not SkipProcessing */
  135.  
  136.         Do_FileMenu(FALSE,theItem,&SkipProcessing);                 /* Post menu handler */
  137.  
  138. }                                                                                /* End of procedure */
  139.  
  140. /* ======================================================= */
  141.  
  142.  
  143. /* Routine: DoMenuEdit */
  144. /* Purpose: Handle all menu items in this list */
  145.  
  146. void DoMenuEdit( theItem)                                                 /* Handle this menu selection */
  147. short        theItem;
  148. {
  149.         Boolean    SkipProcessing;                                           /* TRUE says skip processing */
  150.         Boolean    BoolHolder;                                                 /* For SystemEdit result */
  151.  
  152.  
  153.  
  154.         SkipProcessing = FALSE;                                             /* Set to not skip the processing of this menu item */
  155.  
  156.         Do_EditMenu(TRUE,theItem,&SkipProcessing);                  /* Pre menu handler */
  157.  
  158.         if (SkipProcessing == FALSE)                                       /* See if process the menu list */
  159.             {
  160.  
  161.                 BoolHolder = SystemEdit ( theItem - 1 );                   /* Let the DA do the edit to itself */
  162.  
  163.                 if  (BoolHolder == FALSE)                                     /* If not a DA then we get it */
  164.                     {                                                                /* Handle by using a Case statment */
  165.  
  166.                         switch (theItem) {                                        /* Handle all commands in this menu list */
  167.  
  168.                                 case MItem_Undo:
  169.                                 break;
  170.  
  171.                                 case MItem_Cut:
  172.                                 break;
  173.  
  174.                                 case MItem_Copy:
  175.                                 break;
  176.  
  177.                                 case MItem_Paste:
  178.                                 break;
  179.  
  180.                                 case MItem_Clear:
  181.                                 break;
  182.  
  183.                                 case MItem_Select_All:
  184.                                 break;
  185.  
  186.                                 case MItem_Show_Clipboard:
  187.                                 break;
  188.  
  189.                                 default:                                              /* Send to a DA */
  190.                                             break;
  191.  
  192.                         }                                                             /* End of item case */
  193.                     }                                                                /* End of not BoolHolder */
  194.  
  195.             }                                                                      /* End of not SkipProcessing */
  196.  
  197.         Do_EditMenu(FALSE,theItem,&SkipProcessing);                 /* Post menu handler */
  198.  
  199. }                                                                                /* End of procedure */
  200.  
  201. /* ======================================================= */
  202.  
  203. /* Routine: Handle_My_Menu */
  204. /* Purpose: Vector off to the appropiate menu list handler */
  205.  
  206. void Handle_My_Menu(  theMenu, theItem)
  207. short    theMenu;
  208. short    theItem;
  209. {
  210.  
  211.  
  212.         switch (theMenu)                                                     /* Do selected menu list */
  213.         {
  214.  
  215.                 case Res_Menu_Apple:
  216.                             DoMenuApple(theItem);                              /* Go handle this menu list */
  217.                             break;
  218.  
  219.                 case Res_Menu_File:
  220.                             DoMenuFile(theItem);                                 /* Go handle this menu list */
  221.                             break;
  222.  
  223.                 case Res_Menu_Edit:
  224.                             DoMenuEdit(theItem);                                 /* Go handle this menu list */
  225.                             break;
  226.  
  227.                 default:
  228.                             Handle_Other_Menus(theMenu,theItem);          /* Handle other special menus */
  229.                             break;
  230.  
  231.         }                                                                         /* End for the Lists */
  232.  
  233.         HiliteMenu(0);                                                         /* Turn menu selection off */
  234. }                                                                                /* End of procedure Handle_My_Menu */
  235.  
  236.